<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>抽茧剥丝</title>
</head>

<body>
    <!--var arr = ['鸡腿',101,'3','奥利奥',9,false,'33a',1.333,'巧克力'];
求数组中所有类型为number的整数之和-->
    <script>
        var arr = ['鸡腿', 101, '3', '奥利奥', 9, false, '33a', 1.333, '巧克力'];
        var sum = 0;
        // for (var i = 0; i < arr.length; i++) {
        //     var num = Number(arr[i]);
        //     if (!isNaN(num)&&num%1===0) {
        //         sum += num;
        //     }
        // }
        //for（var i=0,1en=arr.length;i<len；i++）{

        for(var i = 0, len = arr.length; i < len; i++){
            if(typeof arr[i] === "number" && arr[i] % 1 === 0){
                sum +=arr[i];
            }
        }
        console.log(sum);


        //~~arr[i]=arr[i] 取整为自己本身就是整数
    </script>
</body>

</html>